//  Copyright (c) 2008  Yoong-ki Ahn & Youngjin Kim < mexif@googlegroups.com>
//  See the enclosed file COPYING for license information (MIT Licence).
//  If you did not receive this file,
//  see http://www.opensource.org/licenses/mit-license.php.

#ifndef _COMMON_H_
#define _COMMON_H_

#include <stdio.h>
#include <list>
#include <string>
#include <vector>

typedef std::list< std::string > string_list;

string_list load_text( const char* filename );
void save_text( const char* filename, string_list& lines );
void print_text( string_list& lines );

typedef std::vector< std::string > string_array;
string_array split_text( std::string str, std::string chars );
std::string  join_text( std::string sep, string_array& arr, size_t index );

struct MakerTag
{
	std::string			prefix;

	bool				hasVirtual;
    unsigned int        id;
    std::string         name;
    std::string         desc;
    std::string         type;
    std::string         comment;

    string_array         others;
};

typedef std::list<MakerTag>     maker_tag_list;
maker_tag_list parse_maker_tag( string_list& lines );
void print_tags( maker_tag_list& tags );

struct Option
{
    std::string         header;
    std::string         source;
    std::string         str_type;
    std::string         tagdb_type;
	std::string         meta_type;
    std::string         exif_macro;
    std::string         exif_array;
    std::string         exif_search;
	std::string         exif_meta;
    std::string         exif_string;
};

Option fill_option( std::string filename, string_list& lines );
std::string make_string( const char* fmt, ... );
std::string gen_space( size_t x );
std::string make_db_name( Option& opt, std::string& prefix );
std::string make_search_name( Option& opt, std::string& prefix );
std::string make_meta_name( Option& opt );
std::string make_tagid_macro( Option& opt, MakerTag& tag );
std::string make_tagid_count_macro( Option& opt, std::string& prefix );

void gen_tagid_macro( Option& opt, maker_tag_list& tags, string_list& header );
void gen_tagid_db( Option& opt, maker_tag_list& tags, string_list& header, string_list& source );
void gen_tagid_string( Option& opt, maker_tag_list& tags, string_list& header, string_list& source );
void gen_tagid_meta( Option& opt, maker_tag_list& tags, string_list& header, string_list& source );

#endif

